package com.huayue.point.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huayue.point.bean.PointPo;
import com.huayue.point.bean.RankPo;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;

public interface PointMapper extends BaseMapper<PointPo> {
    @Select("SELECT sum(point) FROM t_points WHERE user_id = #{userId}")
    Integer querySum(Integer userId);

    @Select("SELECT user_id AS userId,sum(point) point FROM t_points GROUP BY user_id ORDER BY sum(point) DESC")
    Collection<RankPo> rank();
}
